﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;
using System.Data.SqlClient;

namespace IEWebSite
{
	public class IEWebSiteRolProvider:RoleProvider
	{
		public override void AddUsersToRoles(string[] usernames, string[] roleNames)
		{
			throw new NotImplementedException();
		}

		public override string ApplicationName
		{
			get
			{
				throw new NotImplementedException();
			}
			set
			{
				throw new NotImplementedException();
			}
		}

		public override void CreateRole(string roleName)
		{
			throw new NotImplementedException();
		}

		public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
		{
			throw new NotImplementedException();
		}

		public override string[] FindUsersInRole(string roleName, string usernameToMatch)
		{
			throw new NotImplementedException();
		}

		public override string[] GetAllRoles()
		{
			throw new NotImplementedException();
		}

		public override string[] GetRolesForUser(string username)
		{
			List<String> roleList = new List<string>();
			using (SqlConnection sqlConn = Utils.GetSqlConnection())
			{
				sqlConn.Open();
				SqlCommand sqlComm = new SqlCommand("SELECT UserRole FROM SysUserRole SUR JOIN dbo.[USER] U ON SUR.IdSysUserRole = U.IdSysUserRole WHERE Username = '" + username + "'", sqlConn);
				SqlDataReader sqlDataReader = sqlComm.ExecuteReader();
				while (sqlDataReader.Read())
				{
					roleList.Add(sqlDataReader["UserRole"].ToString());
				}
			}
			return roleList.ToArray();
		}

		public override string[] GetUsersInRole(string roleName)
		{
			throw new NotImplementedException();
		}

		public override bool IsUserInRole(string username, string roleName)
		{
			throw new NotImplementedException();
		}

		public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
		{
			throw new NotImplementedException();
		}

		public override bool RoleExists(string roleName)
		{
			throw new NotImplementedException();
		}
	}
}
